﻿using MvcApplication.Entity;
using System.Data.Entity.ModelConfiguration;

namespace MvcApplication.Data.Mapping
{
    public class Post_Mapping : EntityTypeConfiguration<Post>
    {
        public Post_Mapping()
        {
            this.HasKey(t => t.ID);
            this.ToTable("Post");

            this.HasMany(t => t.Categories).WithMany(t=> t.Posts).Map(t =>
            {
                t.ToTable("PostCategory");
                t.MapLeftKey("PostID");
                t.MapRightKey("CategoryID");
            });

            this.HasMany(t => t.DisPlayInfoes).WithOptional().HasForeignKey(t => t.PostID);
        }
    }
}
